<template>
	<view>
		<scroll-view scroll-y class="page">
			<!-- 头部 -->
			<cu-custom bgColor="bg-rgb" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">质检项目</block>
			</cu-custom>
			<!-- 数据列表 -->
			<view class="list">
				<view class="card animation-slide-bottom" v-for="(item,index) in list" :key="index" 
				 :style="[{animationDelay: (index + 1)*0.1 + 's'}]">
					<view class="top">
						<view class="left">移动编号：<text>{{item.mobileCode}}</text></view>
						<view class="right">{{item.mobileType}}</view>
					</view>
					<view class="line"></view>
					<view class="bottom">
						<view class="box">
							<view class="lable">
								料号:
							</view>
							<view class="content">
								{{item.materielCode}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								名称:
							</view>
							<view class="content">
								{{item.materielName}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								规格:
							</view>
							<view class="content">
								{{item.materielGauge}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								数量:
							</view>
							<view class="content">
								{{item.inputNum}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								单位:
							</view>
							<view class="content">
								{{item.inputUnit}}
							</view>
						</view>
						<!-- <view class="box">
							<view class="lable">
								预留编号:
							</view>
							<view class="content">
								{{item.reserveCode}}
							</view>
						</view> -->
						<view class="box">
							<view class="lable">
								位置:
							</view>
							<view class="content">
								{{item.storageSite}}
							</view>
						</view>
					</view>
					<view class="line"></view>
					<view class="btns">
						<view class="btn1" @click="qualityTesting(item)">质检</view>
					</view>
				</view>
			</view>
			<view class="none" v-if="noDataAvailable">
				<view class="none1">
					暂无数据
				</view>
			</view>
			<view class="none2" v-if="noMoreDataAvailable">
				没有更多数据
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name: 'inspectDetail',
		data() {
			return {
				list: [], // 质检项目   根据凭证抬头ID查询
				pageNo: 1, // 上来加载 分页
				noDataAvailable: false, // 暂无数据 状态
				noMoreDataAvailable: false, // 没有更多数据 状态
				id:''
			}
		},
		onShow() {
			this.pageNo = 1
			this.list = []
			this.id = uni.getStorageSync('inspectId'); // 获取凭证抬头ID  根据上一级页面缓存 获取
			this.getListMesCertificateItemByMainId(); // 获取质检项目
		},
		onLoad(e) {
			
		},
		onPullDownRefresh: function() {
			let _this = this
			_this.pageNo = 1
			_this.list = []
			setTimeout(function() {
				uni.stopPullDownRefresh();
				_this.getListMesCertificateItemByMainId()
			}, 1000);
		},
		onReachBottom: function() {
			let _this = this
			if (this.noDataAvailable == true || this.noMoreDataAvailable == true) {
				return
			}
			_this.pageNo++
			_this.getListMesCertificateItemByMainId()
		},
		methods: {
			// 物料凭证抬头-分页列表查询
			getListMesCertificateItemByMainId() {
				uni.showLoading({
					mask:true,
					title:'加载中.....'
				})
				let data = {
					pageNo: this.pageNo,
					pageSize: 10,
					perkId:this.id,
					ifInspect:'否'
				}
				this.$http.get('storage/mesCertificatePerk/checkMesCertificate', {
					params: data
				}).then(res => {
					uni.hideLoading()
					if (res.data.success) {
						this.list = this.list.concat(res.data.result.records);
						if (this.list.length == 0) {
							this.noDataAvailable = true;
						} else if (this.list.length > 0 && res.data.result.records.length == 0) {
							this.noMoreDataAvailable = true;
						} else if (res.data.result.total <= this.pageNo * 10) {
							this.noMoreDataAvailable = true;
						}
						console.log(this.list)
					} else {
						// this.$tip.error(res.data.message)
            this.modal.show({ type:'error', content:res.data.message })
					}
				})
			},
			qualityTesting(item){
				uni.setStorageSync('inspectDetailObj',item);
				this.$Router.push({
					name: 'inspectQuality'
				})
			}
		},
	}
</script>

<style lang="less">
	page {
		background-color: #f1f1f1;
		.card {
			margin: 30rpx;
			box-shadow: 0px 0px 5rpx 2rpx rgba(0, 0, 0, 0.1);
			border-radius: 10rpx;
			background-color: white;
			.top {
				display: flex;
				align-items: center;
				justify-content: space-between;
				// border-bottom: 20rpx solid #F0F0F0;
				// padding-bottom: 20rpx;
				font-weight: bold;
				padding:20rpx 30rpx;
				.left{
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #485A75;
					line-height: 50rpx;
				}
				.right{
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #191919;
					line-height: 50rpx;
				}
			}
			.line{
				width: 750rpx;
				height: 10rpx;
				background: #F3F5F9;
			}
			.bottom{
				padding:20rpx 30rpx;
				.box {
					display: flex;
					justify-content: space-between;
					padding: 20rpx 0;
					align-items: center;
					.lable {
						color: #485A75;
						font-size: 28rpx;
					}
					.content {
						width: 70%;
						text-align: right;
						color: #191919;
						font-weight: bold;
						word-break: break-all;
					}
					.shrink{
						height: 40rpx;
						overflow: hidden;
						white-space: nowrap;/*不换行*/
						text-overflow:ellipsis;/*超出部分文字以...显示*/
					}
				}
			}
			.btns {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 20rpx;
				font-size: 25rpx;
				padding:20rpx 30rpx;
				view{
					width: 180rpx;
					height: 64rpx;
					line-height: 50rpx;
					color: white;
					border-radius: 30rpx;
					padding: 10rpx 20rpx;
					text-align: center;
				}
				.btn1 {
					background-image: radial-gradient(circle,#3F55E9,#5F71ED,#7D8CF0);
					margin-left: 450rpx;
				}
			}
		}
	}
	.none .none1 {
		font-size: 30rpx;
		text-align: center;
		margin-top: 50rpx;
		color: #999999;
	}

	.none2 {
		font-size: 30rpx;
		text-align: center;
		margin-top: 50rpx;
		color: #999999;
	}
</style>
